package com.peenongsaban.freelance.action;

import com.opensymphony.xwork2.ActionSupport;
import com.peenongsaban.freelance.model.LoginModel;
import com.peenongsaban.freelance.service.LoginService;

public class LoginAction extends ActionSupport {
	private LoginModel model = new LoginModel();
	private static final long serialVersionUID = 1L;

	public String login() {

		LoginService service = new LoginService();
		boolean result = service.verifyLogin(model.getUsername(), model.getPassword());
		if(result){
			return SUCCESS;
		}else{
			return LOGIN;
		}		
	}
	
	public String prepareLogin(){
		
		 System.out.println(model.getUrl());
		return SUCCESS;
	}
	
	public String logout(){
		LoginService service = new LoginService();
		service.logout();
		return SUCCESS;
	}

	public LoginModel getModel() {
		return model;
	}

	public void setModel(LoginModel model) {
		this.model = model;
	}

}
